package com.atguigu.dao.impl;

import com.atguigu.dao.PortDao;
import com.atguigu.pojo.OrderItem;
import com.atguigu.pojo.Port;

import java.util.List;

public class PortDaoImpl extends BaseDao implements PortDao {
    @Override
    public Integer addPort(Port port) {
        System.out.println("PortDaoImpl程序在["+Thread.currentThread().getName()+"]线程中");
        String sql="insert into t_port(`id`,`serviceId`,`number`) values(?,?,?);";
        return update(sql,port.getId(),port.getServiceId(),port.getNumber());
    }

    @Override
    public List<Port> queryPortsByServiceId(String serviceId) {
        String sql ="select `id`,`serviceId`,`number` from t_port where serviceId = ?";
        return queryForList(Port.class,sql,serviceId);
    }

    @Override
    public Port queryPortByServiceIdAndNumber(String serviceId, String number) {
        String sql ="select `id`,`serviceId`,`number` from t_port where serviceId = ? and number= ?";
        return queryForOne(Port.class,sql,serviceId,number);
    }
}
